﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace GMAC.ReportingSystem.UserControls
{
    public partial class wucMessage : System.Web.UI.UserControl
    {
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //pnlMensaje.Visible = false;
        }

        /// <summary>
        /// Shows the message.
        /// </summary>
        /// <param name="messageType">Type of the message.</param>
        /// <param name="message">The message.</param>
        /// <param name="description">The description.</param>
        public void ShowMessage(MessageType messageType, string message, string description)
        {
            if (string.IsNullOrEmpty(message))
            {
                throw new System.ArgumentException("El mensaje no puede ser vacio");
            }

            this.MessageType = messageType;
            this.Message = message;
            this.Description = description;
            ShowMessage();
        }


        /// <summary>
        /// Shows the message.
        /// </summary>
        public void ShowMessage()
        {
            if (string.IsNullOrEmpty(this.Message))
            {
                throw new System.ArgumentException("El mensaje no puede ser vacio");
            }

            pnlMensaje.Visible = true;
            //pnlMensaje.Height = Unit.Pixel(1000);

            switch (this.MessageType)
            {
                case MessageType.Success:
                    imgMensaje.ImageUrl = "~/App_Themes/Theme/Images/b_apro.gif";
                    break;
                case MessageType.Information:
                    imgMensaje.ImageUrl = "~/App_Themes/Theme/Images/b_importante.gif";
                    break;
                case MessageType.Error:
                    imgMensaje.ImageUrl = "~/App_Themes/Theme/Images/b_error.gif";
                    break;
                default:
                    break;
            }

            lblMensaje.Text = Message;
        }

        /// <summary>
        /// Gets or sets the message.
        /// </summary>
        /// <value>The message.</value>
        public string Message { get; set; }

        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        /// <value>The description.</value>
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the type of the message.
        /// </summary>
        /// <value>The type of the message.</value>
        public MessageType MessageType { get; set; }
    }

    /// <summary>
    /// Enumeracion de tipo de mensajes
    /// </summary>
    public enum MessageType
    {
        /// <summary>
        /// Informativo
        /// </summary>
        Information = 0,

        /// <summary>
        /// Existoso
        /// </summary>
        Success = 1,

        /// <summary>
        /// Error
        /// </summary>
        Error = 2,
    }
}
